package per.sunmes.cl.g.data.cards;

import per.sunmes.cl.g.actor.Card;
import per.sunmes.cl.g.actor.Zone;
import per.sunmes.cl.g.data.CardEffect;
import per.sunmes.cl.g.i.CallBack;
import per.sunmes.cl.g.screen.GameScreen;
import per.sunmes.cl.g.sys.LM;
import per.sunmes.cl.g.sys.RandU;

import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.utils.Array;

public class CardEffect7 implements CardEffect {
	// 基本类型
	// 占领当前区域
	@Override
	public void effect(GameScreen gameScreen, Zone selfZone, Card cardSelf) {
		selfCardMoveLandEffect(gameScreen, selfZone, cardSelf, new CallBack() {
			@Override
			public void call() {
				selfZone.setCard(cardSelf);

				Array<Zone> valids = new Array<Zone>();
				for (int y = 0; y < LM.mapYCount; y++) {
					for (int x = 0; x < LM.mapXCount; x++) {
						Zone zone = selfZone.getZoneMap()[x][y];
						if (zone != null
								&& zone.getPlayer() != cardSelf.getPlayer()) {
							valids.add(zone);
						}
					}
				}

				validZone(gameScreen, valids.get(RandU.rand(0, valids.size)),
						cardSelf.getPlayer());
			}
		});
		// ///
		gameScreen.delayActionExecuteNextRound(0.4f);
	}

	@Override
	public void preEffect(GameScreen gameScreen, Zone selfZone, Card cardSelf,
			Group previewGroup) {
		// preEffectCardSelfLand(gameScreen, selfZone, cardSelf, previewGroup);
	}

	@Override
	public boolean isCouldPutToZone(Zone zone) {
		return zone.getCard() == null;
	}

}
